<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>编辑</title>
<%@include file="../common/include.jsp"%>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="col-lg-8">
				<form id="form" role="form">
					<input id="id" name="id" value="${ data.id}" hidden>
					<div class="form-group">
						<label for="name">username</label> <input type="text" class="form-control" id="username" name="username" value="${ data.username }"
							placeholder="请输入username">
					</div>
					<div class="form-group">
						<label for="name">password</label> <input type="text" class="form-control" id="password" name="password" value="${ data.password }"
							placeholder="请输入password">
					</div>
					<div class="form-group">
						<label for="name">enabled</label> <input type="text" class="form-control" id="enabled" name="enabled" value="${ data.enabled }" placeholder="请输入enabled">
					</div>
					<div class="form-group">
						<label for="name">createDate</label> <input type="text" class="form-control" id="createDate" name="createDate" value="${ data.createDate }"
							placeholder="请输入createDate">
					</div>
					<div class="form-group">
						<label for="name">age</label> <input type="text" class="form-control" id="age" name="age" value="${ data.age }" placeholder="请输入age">
					</div>
					<div class="form-group">
						<label for="name">name</label> <input type="text" class="form-control" id="name" name="name" value="${ data.name }" placeholder="请输入name">
					</div>
					<button type="button" onclick="save()" class="btn btn-default">保存</button>
					<button type="reset" onclick="history.back(-1);" class="btn btn-default">取消</button>
				</form>
			</div>
		</div>
	</div>
	<script>
		function save() {
			$.ajax({
				type : 'POST',
				url : '${ctx}/demo/user/save',
				data : $('#form').serialize(),
				dataType : 'json',
				success : function(data) {
					alert(data.msg);
					if (data.success) {
						setTimeout('toIndex("demo/user/")', 100);
					}
				},
				error : function() {
					alert("出错了,请重试!");
				}
			});
		}
	</script>
</body>
</html>
